<template>
  <div class="accordion_box w">
    <div v-if="itemTitle!=''" class="accordion_title">{{ itemTitle }}</div>
    <div class="accordion_group">
      <div
        class="accordion_group_item"
        v-for="item in itemList"
        :key="item.id"
        :style="{ 'background-image': 'url(' + item.backgroundUrl + ')' }"
      >
        <div class="accordion_group_item_mask">
          <img class="accordion_group_item_mask_icon" :src="item.icon" />
          <p class="accordion_group_item_mask_icon_desc">
            {{ item.iconDesc }}
          </p>

          <div class="accordion_group_item_mask_other">
            <p class="accordion_group_item_mask_other_text">
              {{ item.text }}
            </p>
            <div class="accordion_group_item_mask_other_btn">
              <a :href="item.url" target="blank">了解更多</a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Direction",
  props: {
    itemList:{
        type: Array,
        require: true
    },
    itemTitle: {
        type: String,
        default: ''
    }
  },
  data() {
    return {
    };
  },
};
</script>

<style lang="scss" scoped>
/**手风琴*/
.accordion_box {
  /***标题*/
  .accordion_title {
    color: #2f65cc;
    text-align: center;
    font-size: 34px;
    padding: 40px 0;
  }
  /***卡片组*/
  .accordion_group {
    height: 350px;
    display: flex;
    justify-content: space-between;
    margin-right: -20px;
    margin-bottom: 20px;

    .accordion_group_item {
      flex: 1;
      position: relative;
      background-repeat: no-repeat;
      background-size: cover;
      transition: all 0.3s;
      user-select: none;
      margin-right: 20px;
      border-radius: 8px;
      overflow: hidden;
      .accordion_group_item_mask {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        padding-top: 80px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: rgba(0, 0, 0, 0.3);
        transition: all 0.3s;
        .accordion_group_item_mask_icon {
          width: 80px;
          height: 80px;
        }
        .accordion_group_item_mask_icon_desc {
          margin-top: 18px;
          font-size: 24px;
          font-family: SimHei;
          font-weight: 400;
          color: #ffffff;
          line-height: 1;
          position: relative;
        }
        .accordion_group_item_mask_icon_desc:before {
          content: "";
          display: none;
          width: 66px;
          height: 2px;
          background: #ffffff;
          position: absolute;
          bottom: -14px;
          left: 50%;
          margin-left: -33px;
        }
        .accordion_group_item_mask_other {
          display: flex;
          flex-direction: column;
          align-items: center;
          transform: translate3d(-270%, 0, 0);
          color: #fff;
          margin-top: 20px;
          .accordion_group_item_mask_other_text {
            display: block;
            line-height: 26px;
          }
          .accordion_group_item_mask_other_btn {
            padding: 10px 26px;
            border: 1px solid #fff;
            border-radius: 200px;
            line-height: 1;
            margin-top: 16px;
            cursor: pointer;
            a {
              color: #fff;
            }
          }
        }
      }
    }
    .accordion_group_item:hover {
      flex: 2;
      .accordion_group_item_mask {
        padding-top: 0px;
        background: rgba(47, 101, 204, 0.8);
        .accordion_group_item_mask_icon_desc:before {
          display: block;
        }
        .accordion_group_item_mask_other {
          animation: fadeInLeft 1s 0.3s;
          animation-fill-mode: forwards;
        }
      }
    }
  }
}
@keyframes fadeInLeft {
  0% {
    opacity: 0;
    transform: translate3d(-100%, 0, 0);
  }
  100% {
    opacity: 1;
    transform: translateZ(0);
  }
}
</style>
